import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MatClassVO, MatClassForm, MatClassQuery } from '@/api/wmscloud/matClass/types';

/**
 * 查询所有物料分类
 * @returns {*}
 */

export const listAllClass = (): AxiosPromise<MatClassVO[]> => {
  return request({
    url: '/wmsCloud/matClass/listAll',
    method: 'get'
  });
};

/**
 * 查询物料分类列表
 * @param query
 * @returns {*}
 */

export const listMatClass = (query?: MatClassQuery): AxiosPromise<MatClassVO[]> => {
  return request({
    url: '/wmsCloud/matClass/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料分类详细
 * @param classId
 */
export const getMatClass = (classId: string | number): AxiosPromise<MatClassVO> => {
  return request({
    url: '/wmsCloud/matClass/' + classId,
    method: 'get'
  });
};

/**
 * 新增物料分类
 * @param data
 */
export const addMatClass = (data: MatClassForm) => {
  return request({
    url: '/wmsCloud/matClass',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料分类
 * @param data
 */
export const updateMatClass = (data: MatClassForm) => {
  return request({
    url: '/wmsCloud/matClass',
    method: 'put',
    data: data
  });
};

/**
 * 删除物料分类
 * @param classId
 */
export const delMatClass = (classId: string | number | Array<string | number>) => {
  return request({
    url: '/wmsCloud/matClass/' + classId,
    method: 'delete'
  });
};
